package com.ymatou.query.trading.api.testcase;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.query.seller.trading.api.parameter.Common;
import com.ymatou.query.trading.api.parameter.GetBondedProductInfoBean;
import com.ymatou.query.trading.api.parameter.resp.GetBondedProductInfoResp;
import com.ymatou.query.trading.api.parameter.results.GetBondedProductInfoResult;
import com.ymatou.query.trading.api.parameter.sp.Sp_GetBondedProductInfo;
import com.ymatou.query.trading.api.service.GetBondedProductInfoCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P3;
import com.ymttest.common.entitie.BondedProductInfo;
import com.ymttest.common.enums.BondedAreaEnum;
import com.ymttest.common.enums.LogisticsTypeEnum;
import com.ymttest.common.enums.OrderStatusEnum;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.YMTDateUtil;
import com.ymttest.utils.constant.ECode;

/**
 * 获取保税商品信息 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_GetBondedProductInfo {

    private static GetBondedProductInfoBean request;

    private static GetBondedProductInfoCall getbondedproductinfocall;

    @BeforeClass
    public static void setUp() {
        Logger.createResultFile("获取保税商品信息");
    }

    @Before
    public void caseUp() {

        request = new GetBondedProductInfoBean();
        getbondedproductinfocall = new GetBondedProductInfoCall();
    }

    @AfterClass
    public static void tearDown() {
        Logger.generateResult(getbondedproductinfocall.getOpurl());
    }

    @After
    public void caseDown() {
        Logger.end();
    }
    
    private void verify(){
    	GetBondedProductInfoResp expectResponse = new GetBondedProductInfoResp();
    	ConstructExpectedResponse(expectResponse);
    	GetBondedProductInfoResp actualResponse = getbondedproductinfocall.getBondedProductInfoResp();
    	List<BondedProductInfo> expects = expectResponse.getBondedProductInfoList();
    	List<BondedProductInfo> actuals = actualResponse.getBondedProductInfoList();
    	if(expects==null){
    		DataUtil.verify(null, actuals, "验证BondedProductInfoList == null");
    	}else{
    		boolean sameSize = expects.size()==actuals.size();
    		DataUtil.verify(expects.size(), actuals.size(), "验证BondedProductInfoList.size()");
    		if(sameSize){
    			for(BondedProductInfo expect:expects){
//    				boolean exsit = actuals.stream().anyMatch(x->x.equals(expect));
//    				DataUtil.verify(true, exsit, "验证\n"+expect+"\n的BondedProductInfo对象是否存在于BondedProductInfoList列表中");
    			}
    		}
    	}
    }
    
    @SuppressWarnings("rawtypes")
	private void ConstructExpectedResponse(GetBondedProductInfoResp response){
    	Map<String, List<Map>> results = execute();
    	GetBondedProductInfoResult result = ConvertResult(results);
    	List<GetBondedProductInfoResult.YmtOrderInfo> orderInfos = result.getOrderInfos();
    	List<BondedProductInfo> bondedProductInfoList = new ArrayList<BondedProductInfo>();
    	orderInfos.forEach(x->bondedProductInfoList.add(ConvertOrderInfoToBondedProductInfo(x)));
    	response.setBondedProductInfoList(bondedProductInfoList);
    }
    
	private BondedProductInfo ConvertOrderInfoToBondedProductInfo(
			GetBondedProductInfoResult.YmtOrderInfo oi) {
		GetBondedProductInfoResult.YmtOrder order = oi.getOrder();
		GetBondedProductInfoResult.YmtOrderSummary orderSummary = order
				.getYmt_OrderSummary();
		GetBondedProductInfoResult.YmtUser buyer = order.getYmt_User();
		if(buyer == null){
			buyer = new GetBondedProductInfoResult.YmtUser();
		}

		int tradingId = order.getTradingItem() == null ? 0 : order
				.getTradingItem().getiTradingId();

		GetBondedProductInfoResult.YmtIdPic idPic = order.getIdPic();
		String[] addressArray = order.getsAddress().split(",");

		String strBonderArea = DataUtil.Stringg.Empty;
		if (oi.getiBondedArea() != null) {
			int i = oi.getiBondedArea();
			if (i == BondedAreaEnum.GuangZhou.getValue()) {
				strBonderArea = "广州保税区";
			} else if (i == BondedAreaEnum.NingBo.getValue()) {
				strBonderArea = "宁波保税区";
			}
		}

		BondedProductInfo bondedProductInfo = new BondedProductInfo();
		bondedProductInfo.setOrderNo(order.getiOrderId());
		bondedProductInfo
				.setOrderNote(order.getYmt_O_OrderNote() != null ? order
						.getYmt_O_OrderNote().getsContent()
						: DataUtil.Stringg.Empty);
		bondedProductInfo.setLeaveWord(order.getsLeaveWord());
		bondedProductInfo.setTelephone(order.getsTelephone());
		bondedProductInfo.setAddTime(order.getdAddTime());
		bondedProductInfo
				.setOrderState(Common.GetOrderStatusForSeller(
						order.getiTradingStatus(),
						order.getiRiskVerifiedStatus(), null));
		bondedProductInfo.setRiskVerifiedStatus(order.getiRiskVerifiedStatus());
		bondedProductInfo.setIsPaidInFull(order.isbPaidInFull());
		bondedProductInfo.setBuyerLoginId(order.getsBuyerLoginId());
		bondedProductInfo.setBuyerPhone(buyer.getsPhone());
		bondedProductInfo.setBuyerName("");
		bondedProductInfo.setReceivePerson(order.getsReceivePerson());
		bondedProductInfo.setReceiveEmail(order.getsEmail() == null ? buyer
				.getsLoginEmail() : "");
		bondedProductInfo.setTotalPrice(order.GetCurrentAmountOfCash());
		bondedProductInfo.setPhone(order.getsPhone());
		bondedProductInfo.setReceiverCertificateNo(idPic != null ? idPic
				.getsCardId() : "");
		bondedProductInfo
				.setProvince(addressArray.length >= 1 ? addressArray[0] : "");
		bondedProductInfo.setCity(addressArray.length >= 2 ? addressArray[1]
				: "");
		bondedProductInfo.setCounty(addressArray.length >= 3 ? addressArray[2]
				: "");
		bondedProductInfo.setAddress(order.getsAddress());
		bondedProductInfo.setPostCode(order.getsPostCode());
		bondedProductInfo.setProductName(oi.getsTitle().replaceAll("？", ""));
		bondedProductInfo.setFreight(order.getfFreight());
		bondedProductInfo.setProductNum(oi.getiAmount());
		bondedProductInfo.setProductPrice(oi.getfOriginalPrice());
		bondedProductInfo.setBondedArea(strBonderArea);
		bondedProductInfo.setBondedAreaId(oi.getiBondedArea() != null ? oi
				.getiBondedArea() : 0);
		bondedProductInfo.setProductRegisterNo(oi.getsProductCode());
		bondedProductInfo.setPayType("支付宝");
		bondedProductInfo.setPaySerialNo(tradingId != 0 ? String
				.valueOf(tradingId) : "");
		bondedProductInfo.setExpressCompany(orderSummary != null ? orderSummary
				.getsLogisticsProvider() : "");
		bondedProductInfo.setProductNo(oi.getsProductId());
		bondedProductInfo.setProductSku(oi.getsSKU());
		bondedProductInfo.setProductCode(GetSku(oi.getsSKU()));
		bondedProductInfo.setCatalogId(oi.getsCatalogId());

		bondedProductInfo.setCatalogInfo("");
		if (!DataUtil.Stringg.isNullOrEmpty(oi.getsPropertyInfo())) {
			List<String> propertyList = new ArrayList<String>();
			if (oi.getsPropertyInfo().contains(",")) {
				String[] arr = oi.getsPropertyInfo().split(",");
				for (String s : arr) {
					propertyList.add(s);
				}
			} else {
				propertyList.add(oi.getsPropertyInfo());
			}
			StringBuilder strProperty = new StringBuilder();

			propertyList.forEach(z -> {
				String strSecondProperty = z.substring(z.lastIndexOf(":") + 1);
				if (strSecondProperty.contains("#")) {
					strProperty.append(
							strSecondProperty.substring(strSecondProperty
									.lastIndexOf("#") + 1)).append(":");
				} else {
					strProperty.append(strSecondProperty).append(":");
				}
			});
			String str = strProperty.toString();
			if (!DataUtil.Stringg.isNullOrEmpty(str)) {
				if (str.charAt(str.length() - 1) == ':') {
					str = str.substring(0, str.length() - 1);
				}
			}
			bondedProductInfo.setCatalogInfo(str);
		}

		return bondedProductInfo;
	}
    
	private static String GetSku(String s) {
		if (DataUtil.Stringg.IsNullOrWhiteSpace(s))
			return DataUtil.Stringg.Empty;

		int i = s.indexOf(":");
		if (i > -1) {
			return s.substring(0, i);
		}
		return s;
	}
    
    @SuppressWarnings("rawtypes")
    private Map<String, List<Map>> execute(){
    	Sp_GetBondedProductInfo sp = new Sp_GetBondedProductInfo();
    	//存储过程的变量赋值
    	BuildArguments(sp);
    	 return sp.execute();
    }
    
    @SuppressWarnings("rawtypes")
	private GetBondedProductInfoResult ConvertResult(Map<String, List<Map>> results){
    	GetBondedProductInfoResult result = new GetBondedProductInfoResult();
    	List<GetBondedProductInfoResult.YmtOrder> orders = null;
    	List<GetBondedProductInfoResult.YmtOrderInfo> orderInfos = null;
    	List<GetBondedProductInfoResult.YmtTradingItem> tradingItems = null;
    	List<GetBondedProductInfoResult.YmtTradingInfo> tradingInfos = null;
    	List<GetBondedProductInfoResult.YmtOrderState> orderStates = null;
    	List<GetBondedProductInfoResult.YmtUser> users = null;
    	List<GetBondedProductInfoResult.YmtIdPic> pics = null;
    	List<GetBondedProductInfoResult.YmtOrderNote> orderNotes = null;
    	List<GetBondedProductInfoResult.YmtOrderSummary> orderSummaries = null;
    	
    	if(results != null && results.size() > 0){
    		List<Map> orderList = results.get("orders");
    		if(!DataUtil.isNullOrEmpty(orderList)){
    			orders = new ArrayList<GetBondedProductInfoResult.YmtOrder>();
    			for(Map m : orderList){
    				GetBondedProductInfoResult.YmtOrder o = new GetBondedProductInfoResult.YmtOrder();
    				DataUtil.mapToBean(o, m);
    				orders.add(o);
    			}
    		}
    		
    		List<Map> orderInfoList = results.get("orderInfos");
    		if(!DataUtil.isNullOrEmpty(orderInfoList)){
    			orderInfos = new ArrayList<GetBondedProductInfoResult.YmtOrderInfo>();
    			for(Map m : orderInfoList){
    				GetBondedProductInfoResult.YmtOrderInfo o = new GetBondedProductInfoResult.YmtOrderInfo();
    				DataUtil.mapToBean(o, m);
    				orderInfos.add(o);
    			}
    		}
    		
    		List<Map> tradingItemList = results.get("tradingItems");
    		if(!DataUtil.isNullOrEmpty(tradingItemList)){
    			tradingItems = new ArrayList<GetBondedProductInfoResult.YmtTradingItem>();
    			for(Map m : orderInfoList){
    				GetBondedProductInfoResult.YmtTradingItem o = new GetBondedProductInfoResult.YmtTradingItem();
    				DataUtil.mapToBean(o, m);
    				tradingItems.add(o);
    			}
    		}
    		
    		List<Map> tradingInfoList = results.get("tradingInfos");
    		if(!DataUtil.isNullOrEmpty(tradingInfoList)){
    			tradingInfos = new ArrayList<GetBondedProductInfoResult.YmtTradingInfo>();
    			for(Map m : tradingInfoList){
    				GetBondedProductInfoResult.YmtTradingInfo o = new GetBondedProductInfoResult.YmtTradingInfo();
    				DataUtil.mapToBean(o, m);
    				tradingInfos.add(o);
    			}
    		}
    		
    		List<Map> orderStateList = results.get("orderStates");
    		if(!DataUtil.isNullOrEmpty(orderStateList)){
    			orderStates = new ArrayList<GetBondedProductInfoResult.YmtOrderState>();
    			for(Map m : orderStateList){
    				GetBondedProductInfoResult.YmtOrderState o = new GetBondedProductInfoResult.YmtOrderState();
    				DataUtil.mapToBean(o, m);
    				orderStates.add(o);
    			}
    		}
    		
    		List<Map> userList = results.get("users");
    		if(!DataUtil.isNullOrEmpty(userList)){
    			users = new ArrayList<GetBondedProductInfoResult.YmtUser>();
    			for(Map m : userList){
    				GetBondedProductInfoResult.YmtUser o = new GetBondedProductInfoResult.YmtUser();
    				DataUtil.mapToBean(o, m);
    				users.add(o);
    			}
    		}
    		
    		List<Map> picList = results.get("pics");
    		if(!DataUtil.isNullOrEmpty(picList)){
    			pics = new ArrayList<GetBondedProductInfoResult.YmtIdPic>();
    			for(Map m : picList){
    				GetBondedProductInfoResult.YmtIdPic o = new GetBondedProductInfoResult.YmtIdPic();
    				DataUtil.mapToBean(o, m);
    				pics.add(o);
    			}
    		}
    		
    		List<Map> orderNoteList = results.get("orderNotes");
    		if(!DataUtil.isNullOrEmpty(orderNoteList)){
    			orderNotes = new ArrayList<GetBondedProductInfoResult.YmtOrderNote>();
    			for(Map m : orderNoteList){
    				GetBondedProductInfoResult.YmtOrderNote o = new GetBondedProductInfoResult.YmtOrderNote();
    				DataUtil.mapToBean(o, m);
    				orderNotes.add(o);
    			}
    		}
    		
    		List<Map> orderSummaryList = results.get("orderSummaries");
    		if(!DataUtil.isNullOrEmpty(orderSummaryList)){
    			orderSummaries = new ArrayList<GetBondedProductInfoResult.YmtOrderSummary>();
    			for(Map m : orderSummaryList){
    				GetBondedProductInfoResult.YmtOrderSummary o = new GetBondedProductInfoResult.YmtOrderSummary();
    				DataUtil.mapToBean(o, m);
    				orderSummaries.add(o);
    			}
    		}
    		
    	}
    	result.setIdPics(GetIdPics(pics));
    	result.setTradingItems(MergeTradingItem(tradingItems, tradingInfos));
    	result.setOrders(MergeOrder(orders, orderStates, users, orderNotes, orderSummaries, pics, result.getTradingItems()));
    	result.setOrderInfos(GetOrderInfos(orderInfos, orders));
    	return result;
    }

	private List<GetBondedProductInfoResult.YmtOrderInfo> GetOrderInfos(
			List<GetBondedProductInfoResult.YmtOrderInfo> orderInfos,
			List<GetBondedProductInfoResult.YmtOrder> orders) {
		List<GetBondedProductInfoResult.YmtOrderInfo> s = new ArrayList<GetBondedProductInfoResult.YmtOrderInfo>();
		if (!DataUtil.isNullOrEmpty(orderInfos)) {
			for(GetBondedProductInfoResult.YmtOrderInfo item : orderInfos){
				List<GetBondedProductInfoResult.YmtOrder> t = orders.stream().filter(x->x.getiOrderId() == item.getiOrderId()).collect(Collectors.toList());
				if(!DataUtil.isNullOrEmpty(t)){
					item.setOrder(t.get(0));
				}
				s.add(item);
			}
		}
		return s;
	}
    
    private List<GetBondedProductInfoResult.YmtOrder> MergeOrder(List<GetBondedProductInfoResult.YmtOrder> orders, 
    		List<GetBondedProductInfoResult.YmtOrderState> orderStates, 
    		List<GetBondedProductInfoResult.YmtUser> users, 
    		List<GetBondedProductInfoResult.YmtOrderNote> orderNotes, 
    		List<GetBondedProductInfoResult.YmtOrderSummary> orderSummaries,
            List<GetBondedProductInfoResult.YmtIdPic> pics, 
            List<GetBondedProductInfoResult.YmtTradingItem> items){
    	List<GetBondedProductInfoResult.YmtOrder> s = new ArrayList<GetBondedProductInfoResult.YmtOrder>();
    	if(!DataUtil.isNullOrEmpty(orders)){
    		for(GetBondedProductInfoResult.YmtOrder item : orders){
    			int iOrderId = item.getiOrderId();
    			int iUserId = item.getiUserId();
    			
    			GetBondedProductInfoResult.YmtTradingItem i =  item.getTradingItem();
    			
    			List<GetBondedProductInfoResult.YmtOrderState> orderStateList = orderStates.stream().filter(x->x.getiOrderId()==iOrderId).collect(Collectors.toList());
    			if(!DataUtil.isNullOrEmpty(orderStateList)){
    				item.setYmt_OrderStates(orderStateList.get(0));
    			}
    			
    			List<GetBondedProductInfoResult.YmtUser> userList = users.stream().filter(x->x.getiUserId()==iUserId).collect(Collectors.toList());
    			if(!DataUtil.isNullOrEmpty(userList)){
    				item.setYmt_User(userList.get(0));
    			}
    			
    			List<GetBondedProductInfoResult.YmtOrderNote> orderNoteList = orderNotes.stream().filter(x->x.getiOrderId()==iOrderId).collect(Collectors.toList());
    			if(!DataUtil.isNullOrEmpty(orderNoteList)){
    				item.setYmt_O_OrderNote(orderNoteList.get(0));
    			}
    			
    			List<GetBondedProductInfoResult.YmtOrderSummary> orderSummaryList = orderSummaries.stream().filter(x->x.getiOrderId()==iOrderId).collect(Collectors.toList());
    			if(!DataUtil.isNullOrEmpty(orderSummaryList)){
    				item.setYmt_OrderSummary(orderSummaryList.get(0));
    			}
    			
    			List<GetBondedProductInfoResult.YmtIdPic> picList = pics.stream().filter(x->x.getiOrderId()==iOrderId).collect(Collectors.toList());
    			if(!DataUtil.isNullOrEmpty(picList)){
    				item.setIdPic(picList.get(0));
    			}
    			
    			if(i != null){
	    			List<GetBondedProductInfoResult.YmtTradingItem> itemList = items.stream().filter(
	    					x->
	    					x.getiOrderId()==iOrderId
//	    					&& (x.getYmt_TradingInfo().getiTradingStatus() == 2 || isLater(x.getdUpdateTime(),item.getTradingItem() == null?"":item.getTradingItem().getdUpdateTime()))
	    					).collect(Collectors.toList());
	    			if(!DataUtil.isNullOrEmpty(itemList)){
	    				item.setTradingItem(itemList.get(0));
	    			}
    			}
    			s.add(item);
    		}
    	}
    	
    	return s;
    }
    
    private boolean isLater(String d1,String d2){
    	if(d1 == null || d1 == ""){
    		d1 = DataUtil.defaultJavaDateString;
    	}
    	if(d2 == null || d2 == ""){
    		d2 = DataUtil.defaultJavaDateString;
    	}
    	int i = YMTDateUtil.parseDate(d1, YMTDateUtil.YMDHMS).compareTo(YMTDateUtil.parseDate(d2, YMTDateUtil.YMDHMS));
    	if(i>0){
    		return true;
    	}
    	return false;
    }
    
    private List<GetBondedProductInfoResult.YmtIdPic> GetIdPics(List<GetBondedProductInfoResult.YmtIdPic> pics)
    {
    	List<GetBondedProductInfoResult.YmtIdPic> s = new ArrayList<GetBondedProductInfoResult.YmtIdPic>();
    	if(!DataUtil.isNullOrEmpty(pics)){
    		s.addAll(pics);
    	}
        return s;
    }
    
    private List<GetBondedProductInfoResult.YmtTradingItem> MergeTradingItem(List<GetBondedProductInfoResult.YmtTradingItem> tradingItems, List<GetBondedProductInfoResult.YmtTradingInfo> tradingInfos)
    {
    	List<GetBondedProductInfoResult.YmtTradingItem> s = new ArrayList<GetBondedProductInfoResult.YmtTradingItem>();
    	if(!DataUtil.isNullOrEmpty(tradingItems) && !DataUtil.isNullOrEmpty(tradingInfos)){
    		for(GetBondedProductInfoResult.YmtTradingItem item : tradingItems){
    			int iTradingId = item.getiTradingId();
    			List<GetBondedProductInfoResult.YmtTradingInfo> infos = tradingInfos.stream().filter(x->x.getiTradingId() == iTradingId).collect(Collectors.toList());
    			if(!DataUtil.isNullOrEmpty(infos)){
    				item.setYmt_TradingInfo(infos.get(0));
    			}
    			s.add(item);
    		}
    	}
        return s;
    }
    
    /**
     * 存储过程的变量赋值
     * @param sp
     */
    private void BuildArguments(Sp_GetBondedProductInfo sp){
    	sp.setSellerId(request.getUserId());
    	sp.setConsiderCatalogStatus(1);
    	sp.setNow(YMTDateUtil.getBeforeOrNextDay(0, YMTDateUtil.YMDTHMS_STRING));
    	if(request.getCatalogStatus() == null || request.getCatalogStatus() == LogisticsTypeEnum.Unknown.getValue()){
    		sp.setCatalogStatus(4);
    		sp.setCatalogStatus2(5);
    	}else{
    		if (request.getCatalogStatus() == LogisticsTypeEnum.XloboBondedDelivery.getValue()){
//    			var timeZone = Dependencies.Values.BondedTimeout;
//                query.bondedTimeout = timeZone;
    			sp.setBondedTimeout(10); //AppSetting配置文件中BondedTimeout的参数值
    			sp.setCatalogStatus(5);
    			sp.setCatalogStatus2(5);
    			sp.setConsiderAcceptTime(1);
    			sp.setConsiderBondedNoResult(1);
    		}else{
    			sp.setCatalogStatus(4);
    			sp.setCatalogStatus2(4);
    		}
    	}
    	if(request.getBondedArea() !=null && request.getBondedArea() != BondedAreaEnum.Unkown.getValue()){
    		sp.setConsiderBondedArea(1);
    		sp.setBondedArea(request.getBondedArea());
    	}
    	if(!DataUtil.isNullOrEmpty(request.getOrderStates())){
    		if(request.getOrderStates().contains(OrderStatusEnum.OrderPostPay.getValue())
    				&& !request.getOrderStates().contains(OrderStatusEnum.SellerAccept.getValue())){
    			sp.setConsiderPaidInFull(1);
    			sp.setPaidInFull(0);
    		}
    		if(request.getOrderStates().contains(OrderStatusEnum.SellerAccept.getValue())
    				&& !request.getOrderStates().contains(OrderStatusEnum.OrderPostPay.getValue())){
    			sp.setConsiderPaidInFull(1);
    			sp.setPaidInFull(1);
    		}
    		sp.setTradingStatus(request.getOrderStates());
    	}
    	
    	if(request.getDateType() == 1 
    			&& request.getStartDate() != null 
    			&& request.getEndDate() != null){//按照付款时间查询
    		sp.setConsiderPaidTime(1);
    		sp.setStartDate(request.getStartDate());
    		sp.setEndDate(request.getEndDate());
    	}
    	
    	if(request.getIsUploadIdCard() != null){ //是否上传身份证
    		sp.setConsiderIdPic(1);
    		if(request.getIsUploadIdCard()){
    			sp.setNeedIdPic(1);
    		}else{
    			sp.setNeedIdPic(0);
    		}
    	}
    	
    	if(request.getDateType() == 2 
    			&& request.getStartDate() != null 
    			&& request.getEndDate() != null){//按照上传身份证时间查询
    		sp.setConsiderIdPic(1);
    		sp.setNeedIdPic(1);
    		sp.setConsiderIdPicAddTime(1);
    		sp.setStartDate(request.getStartDate());
    		sp.setEndDate(request.getEndDate());
    	}
    }
    
    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_GetBondedProductInfo_001() {
        Logger.start(true, "以付款时间获取保税商品信息成功");
        try {
//            int UserId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			int UserId = Integer.valueOf(EnvSetup.getData("SellerId"));
            BondedAreaEnum area = BondedAreaEnum.HangZhou;
            // 只能传0,4,5 保税物流方式
            LogisticsTypeEnum delivery = LogisticsTypeEnum.XloboBondedDelivery;
            // request.setBondedArea(BondedAreaEnum.GuangZhou);
            request.setBondedArea(area.getValue());
            request.setCatalogStatus(delivery.getValue());
            // 时间筛选方式(1-付款时间 2-上传身份证时间)
            request.setDateType(1);
            request.setIsUploadIdCard(false);
            ArrayList<Integer> OrderStates = new ArrayList<Integer>();
            OrderStates.add(OrderStatusEnum.SellerAcceptCancel.getValue());
            OrderStates.add(OrderStatusEnum.Received.getValue());
//            request.setOrderStates(OrderStates);
            String StartDate = YMTDateUtil.getBeforeOrNextDay(-140);
            String EndDate = YMTDateUtil.getBeforeOrNextDay(1);
            request.setStartDate(StartDate);
            request.setEndDate(EndDate);
            request.setUserId(UserId);
            // 发送请求
            getbondedproductinfocall.setData(request);
            getbondedproductinfocall.callService();
            // 数据检查
            Logger.verifyEquals(ECode.SUCCESS, getbondedproductinfocall.getCode(), "验证Code");
            verify();
        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    // fail 接口查出来的数据比数据库查询的要少
    public void Tc_GetBondedProductInfo_002() {
        Logger.start(true, "以付款时间获取保税商品信息成功");
        try {
            // int UserId = 1692381;
            int UserId = 3383;
//            BondedAreaEnum area = BondedAreaEnum.GuangZhou;
//            // 只能传0,4,5 保税物流方式
//            LogisticsTypeEnum delivery = LogisticsTypeEnum.XloboBondedDelivery;
//            // request.setBondedArea(BondedAreaEnum.GuangZhou);
//            request.setBondedArea(area.getValue());
//            request.setCatalogStatus(delivery.getValue());
//            // 时间筛选方式(1-付款时间 2-上传身份证时间)
//            request.setDateType(1);
//            request.setIsUploadIdCard(false);
            ArrayList<Integer> OrderStates = new ArrayList<Integer>();
            OrderStates.add(OrderStatusEnum.SellerAcceptCancel.getValue());
            OrderStates.add(OrderStatusEnum.Received.getValue());
            request.setOrderStates(OrderStates);
            String StartDate = YMTDateUtil.getBeforeOrNextDay(-40,YMTDateUtil.YMDTHMS_STRING);
            String EndDate = YMTDateUtil.getBeforeOrNextDay(1,YMTDateUtil.YMDTHMS_STRING);
            request.setStartDate(StartDate);
            request.setEndDate(EndDate);
            request.setUserId(UserId);
            // 发送请求
            getbondedproductinfocall.setData(request);
            getbondedproductinfocall.callService();
            Logger.verifyEquals(ECode.SUCCESS, getbondedproductinfocall.getCode(), "验证Code");
            verify();
        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    // 接口查出来的数据要少
    public void Tc_GetBondedProductInfo_003() {
        Logger.start(true, "以付款时间获取保税商品信息成功");
        try {
            // int UserId = 1692381;
            int UserId = 1377309;
            BondedAreaEnum area = BondedAreaEnum.NingBo;
            // 只能传0,4,5 保税物流方式
            LogisticsTypeEnum delivery = LogisticsTypeEnum.BondedDelivery;
            // request.setBondedArea(BondedAreaEnum.GuangZhou);
            request.setBondedArea(area.getValue());
            request.setCatalogStatus(delivery.getValue());
            // 时间筛选方式(1-付款时间 2-上传身份证时间)
            request.setDateType(1);
            request.setIsUploadIdCard(false);
            ArrayList<Integer> OrderStates = new ArrayList<Integer>();
            OrderStates.add(OrderStatusEnum.SellerAcceptCancel.getValue());
            OrderStates.add(OrderStatusEnum.Received.getValue());
            request.setOrderStates(OrderStates);
            String StartDate = YMTDateUtil.getBeforeOrNextDay(-140);
            String EndDate = YMTDateUtil.getBeforeOrNextDay(1);
            request.setStartDate(StartDate);
            request.setEndDate(EndDate);
            request.setUserId(UserId);
            // 发送请求
            getbondedproductinfocall.setData(request);
            getbondedproductinfocall.callService();
            // 数据检查
            Logger.verifyEquals(ECode.SUCCESS, getbondedproductinfocall.getCode(), "验证Code");
            verify();
        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    // fail 按传身份证查，接口数据比数据库查询要少
    public void Tc_GetBondedProductInfo_004() {
        Logger.start(true, "以上传身份证获取保税商品信息成功");
        try {
            // int UserId = 1692381;
            int UserId = 3383;
            BondedAreaEnum area = BondedAreaEnum.HangZhou;
            LogisticsTypeEnum delivery = LogisticsTypeEnum.XloboBondedDelivery;
            // request.setBondedArea(BondedAreaEnum.GuangZhou);
            request.setBondedArea(area.getValue());
            request.setCatalogStatus(delivery.getValue());
            // 时间筛选方式(1-付款时间 2-上传身份证时间)
            request.setDateType(1);
            request.setIsUploadIdCard(true);
            ArrayList<Integer> OrderStates = new ArrayList<Integer>();
            OrderStates.add(OrderStatusEnum.ApplyForPostPay.getValue());
            OrderStates.add(OrderStatusEnum.Received.getValue());
            request.setOrderStates(OrderStates);
            String StartDate = YMTDateUtil.getBeforeOrNextDay(-140);
            String EndDate = YMTDateUtil.getBeforeOrNextDay(1);
            request.setStartDate(StartDate);
            request.setEndDate(EndDate);
            request.setUserId(UserId);
            // 发送请求
            getbondedproductinfocall.setData(request);
            getbondedproductinfocall.callService();
            // 数据检查
            Logger.verifyEquals(ECode.SUCCESS, getbondedproductinfocall.getCode(), "验证Code");
            verify();
        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    
    
    @Test
    @Category(P3.class)
    @TestCase
    public void Tc_GetBondedProductInfo_005() {
        Logger.start(true, "sellerquery2冒烟测试");
        try {
//            int UserId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			int UserId = Integer.valueOf(EnvSetup.getData("SellerId"));
            // request.setBondedArea(BondedAreaEnum.GuangZhou);
//            request.setBondedArea(BondedAreaEnum.HangZhou.getValue());
            // 只能传0,4,5 保税物流方式
//            request.setCatalogStatus(LogisticsTypeEnum.XloboBondedDelivery.getValue());
            // 时间筛选方式(1-付款时间 2-上传身份证时间)
            request.setDateType(1);
//            request.setIsUploadIdCard(false);
//            ArrayList<Integer> OrderStates = new ArrayList<Integer>();
//            OrderStates.add(OrderStatusEnum.SellerAcceptCancel.getValue());
//            OrderStates.add(OrderStatusEnum.Received.getValue());
//            request.setOrderStates(OrderStates);
            request.setStartDate(YMTDateUtil.getBeforeOrNextDay(-140,YMTDateUtil.YMDTHMS_STRING));
            request.setEndDate(YMTDateUtil.getBeforeOrNextDay(-10,YMTDateUtil.YMDTHMS_STRING));
            request.setUserId(UserId);
            // 发送请求
            getbondedproductinfocall.setData(request);
            getbondedproductinfocall.callService();
            // 数据检查
            Logger.verifyEquals(ECode.SUCCESS, getbondedproductinfocall.getCode(), "验证Code");
            verify();
        } catch (Exception e) {
            Logger.fail(e);
        }
    }
}